home *** CD-ROM | disk | FTP | other *** search
- Path: news.telepac.pt!usenet
- From: vortex@telepac.pt (VORTEX)
- Newsgroups: comp.lang.c++
- Subject: CRC READING ERROR HELP PLEASE!!!!
- Date: Mon, 04 Mar 1996 07:07:32 GMT
- Organization: telepac
- Message-ID: <4hdjbo$hab@vivaldi.telepac.pt>
- Reply-To: vortex@telepac.pt
- NNTP-Posting-Host: por2_p1.telepac.pt
- X-Newsreader: Forte Free Agent 1.0.82
-
- Hi, could anyone help me doing a modification to this little program,
- so that when it occures an CRC reading error i can trap the error and
- put my own messagem on the screen, insted of DOS "CRC ERROR READING
- DRIVE... ".
-
- Thanks, keep in touch with me my e-mail
-
-
-
-
-
-
-
-
-
-
-
-
- //
- //This reading 8 files named SOURCE.1 to SOURCE.8
- //& join them together in a final D:\FINAL.EXE
- //
-
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <sys\stat.h>
- #include <io.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <string.h>
-
- #define READ_BYTES (62L * 1024L)
-
- void main(void)
- {
- char buf[READ_BYTES+1];
- char file_on_disk[16]="source.";
- char filename[129]="d:\\final.exe";
- int f_src, f_dst;
- unsigned int bytes;
- int i, num_disks=8;
- char s1[20],s2[4];
-
-
- // Check if destination file exists. If so TRUNCAT to 0 bytes
- // If no CREAT a new one with 0 bytes
-
- if((f_dst= creat(filename, S_IWRITE )) == -1) {
- printf("Cannot open destination file : %s\n",filename);
- exit(1);
- }
-
- close(f_dst);
-
- _dos_creat(filename, O_APPEND, &f_dst);
-
-
- for (i=0;i<num_disks;i++) {
-
- strcpy(s1,file_on_disk);
- itoa(i+1,s2,10); // Converts an Integer to a String
- strcat(s1,s2);
-
- if((f_src = open(s1, O_RDONLY | O_BINARY)) == -1) {
- printf("Cannot open source file: %s\n", s1);
- exit(1);
- }
-
-
- printf("Reading : %s\n",s1);
-
-
-
- // This is where all the work is done (read from source file
- // and write to destination, until done)
-
- while (_dos_read(f_src, buf, READ_BYTES, &bytes)==0) {
- write(f_dst, buf, bytes);
- if (bytes < READ_BYTES) break;
- }
-
- _dos_close(f_src);
-
- }
-
- // Close destination file
-
- close(f_dst);
-
- }
-
-
-
-